//
//  KFDNetworkingTests.m
//  KFD
//
//  Created by JIRENTIANXIANG on 6/5/15.
//  Copyright (c) 2015 KFD. All rights reserved.
//

#import "KFDNetworkingTests.h"
#import "KFDEncryptor.h"
#import "NSURL+convenience.h"
#include "KFDClient.h"
#import "KFDAsyncTestUtil.h"

@implementation KFDNetworkingTests
{
    KFDClient* _client;
}

- (void)setUp {
    [super setUp];
    _client=[KFDClient sharedClient];
}

- (void)tearDown {
    [super tearDown];
}

//-(void)testEncryption
//{
//    NSDictionary* parameters=@{@"nickname":@"Jack",@"gender":@"male",@"password":@"123456"};
//    NSString* result=[KFDEncryptor stringByEncryptingParameters:parameters keyValueSeparator:@"=" parameterSeparator:@"&"];
//    XCTAssert(result.length==32);
//}

//-(void)testURLComposition
//{
//    NSDictionary* parameters=@{@"name":@"Tony",@"password":@"123456",@"status":@"online"};
//    NSURL* url=[NSURL urlWithBaseURL:@"http://www.qq.com/" parameters:parameters];
//    XCTAssert(url.description.length==96);
//}
//
//-(void)testRegister
//{
//    __block BOOL done=NO;
//    [_client registerWithPhoneNubmer:@"18888888801" realName:@"Jack" checkcode:@"123456" successHandler:^{
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        if (response.status==2005) {
//            XCTAssert(YES);
//        }else{
//            XCTAssert(NO);
//        }
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
-(void)testSetNicknameAndPassword
{
    __block BOOL done=NO;
    [_client setNickname:@"Jack" password:@"111111" successHandler:^{
        done=YES;
        XCTAssert(YES);
    } failureHandler:^(KFDResponseBody *response) {
        done=YES;
        XCTAssert(NO);
    }];
    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
              @"Timed out waiting for response asynch method completion");
}

-(void)testLogin
{
    __block BOOL done=NO;
    [_client loginWithPhoneNumber:@"13928430803" password:@"111111" successHandler:^{
        done=YES;
        XCTAssert(YES);
    } failureHandler:^(KFDResponseBody *response) {
        done=YES;
        XCTAssert(NO);
    }];
    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
              @"Timed out waiting for response asynch method completion");
}
//
//-(void)testGetCheckcode
//{
//    __block BOOL done=NO;
//    [_client getCheckcodeWithPhoneNumber:@"18888888888" successHandler:^{
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testGetMarketPrice
//{
//    __block BOOL done=NO;
//    [_client getMarketPriceWithSucessHandler:^(NSArray *marketPrices) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testGetTradingStrategies
//{
//    __block BOOL done=NO;
//    [_client getTradingStrategiesWithMaxCountPerPage:25 page:1 successHandler:^(NSArray *tradingStrategies) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testGetAliveNews
//{
//    __block BOOL done=NO;
//    [_client getAliveNewsWithMaxCountPerPage:100 page:100 successHandler:^(NSArray *aliveNews) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testGetFinancialInfo
//{
//    __block BOOL done=NO;
//    [_client getFinancialInfoWithDate:nil successHandler:^(NSArray *financialData, NSArray *holidayForecast, NSArray *financialEvents) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testGetDiagramData
//{
//    __block BOOL done=NO;
//    [_client getDiagramDataWithType:@"silver" frequency:@"1" successHandler:^(NSArray *diagramPoints) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testGetLiveUrl
//{
//    __block BOOL done=NO;
//    [_client getLiveUrlWithSuccessHandler:^(NSString *url) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testGetAnnouncementList
//{
//    __block BOOL done=NO;
//    [_client getAnnouncementListWithMaxCount:20 page:1 successHandler:^(NSArray *announcementList) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testGetAnnouncement
//{
//    __block BOOL done=NO;
//    [_client getAnnouncementWithId:@"1" successHandler:^(KFDAnnouncement *announcement) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testUpdateAccountInfo
//{
//    __block BOOL done=NO;
//    [_client updateAccountInfoWithNickname:@"haha" province:@"zhejiang" city:@"hangzhou" avatar:@"http://" gender:@1 successHandler:^{
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testGetInvestmentCommunityPosts
//{
//    __block BOOL done=NO;
//    [_client getInvestmentCommunityPostsWithMaxCount:20 page:1 successHandler:^(NSArray *posts) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testPublishPost
//{
//    __block BOOL done=NO;
//    [_client publishInvestmentCommunityPostWithContent:@"最近股市怎么样啊？" pictures:nil successHandler:^(NSString *postId) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testUploadInvestmentCommunityPostPicture
//{
////    NSHTTPCookieStorage* storage=[NSHTTPCookieStorage sharedHTTPCookieStorage];
////    NSArray* cookies=storage.cookies;
////    for (NSHTTPCookie* cookie in cookies) {
////        NSString* name=cookie.name;
////    }
//    __block BOOL done=NO;
//    [_client uploadInvestmentCommunityPostPicture:[UIImage imageNamed:@"avatar.jpeg"] successHandler:^(NSString *pictureId) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testPraiseInvestmentCommunityPost
//{
//    __block BOOL done=NO;
//    [_client praiseInvestmentCommunityPost:@"1" successHandler:^(NSInteger numberOfLikes) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert([response.message isEqualToString:@"您已经赞过了"]);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}
//
//-(void)testCancelPraiseInvestmentCommunityPost
//{
//    __block BOOL done=NO;
//    [_client cancelPraiseInvestmentCommunityPost:@"1" successHandler:^(NSInteger numberOfLikes) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=NO;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}

//-(void)testGetPreferentialActivities
//{
//    __block BOOL done=NO;
//    [_client getPreferentialActivitiesWithType:@"1" maxCount:20 page:1 successHandler:^(NSArray *activities) {
//        done=YES;
//        XCTAssert(YES);
//    } failureHandler:^(KFDResponseBody *response) {
//        done=YES;
//        XCTAssert(NO);
//    }];
//    XCTAssert([KFDAsyncTestUtil waitFor:&done timeout:5],
//              @"Timed out waiting for response asynch method completion");
//}

@end
